package com.henry.javastudy.c04;

import java.util.concurrent.Semaphore;

public class MyRunnable3 implements Runnable {
    private int result=0;
    Semaphore semaphore ;
    public MyRunnable3(Semaphore semaphore)
    {
        this.semaphore=semaphore;

    }    @Override
    public void run() {
        try {
            semaphore.acquire();
            setResult(MyCanculate.sum());
            semaphore.release();
        }
        catch (Exception e){}
    }
    public void setResult(Integer i){
        result=i;
    }
    public int getResult()
    {
        return result;
    }
}
